package com.grand.ch09;

import java.util.LinkedHashMap;

public class LruCache<K,V> extends LinkedHashMap<K,V> {
    private static final long serialVersionUID = -9062508768983283300L;

    //最大容量
    private int maxCapacity;
    public LruCache(int maxCapacity){
        super(16,0.75f,true);
        this.maxCapacity = maxCapacity;
    }

    public int getMaxCapacity(){
        return maxCapacity;
    }

    public void setMaxCapacity(int mc){
        maxCapacity = mc;
    }

    protected boolean removedEldestEntry(java.util.Map.Entry<K,V> eldest){
        if(super.size() > maxCapacity){
            return true;
        }
        return false;
    }




}
